﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Beeflys.Generator
{
    static class MessengerPackageUtil
    {
        private const string MESSENGER_PACKAGE = "Beeflys.MessengerPackage";

        public static string BuildPackage(string protocolId, int state, string data, string opencode, out string packName)
        {
            packName = "messengerPackage";
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.AppendLine($"var messengerPackage = new {MESSENGER_PACKAGE}();");
            stringBuilder.AppendLine($"messengerPackage.version = ActorSystem.version;");
            stringBuilder.AppendLine($"messengerPackage.protocolId = {Generator.DQM}{protocolId}{Generator.DQM};");
            stringBuilder.AppendLine($"messengerPackage.state = {state};");
            stringBuilder.AppendLine($"messengerPackage.data = {data};");
            stringBuilder.AppendLine($"messengerPackage.opencode = {opencode};");
            stringBuilder.AppendLine("messengerPackage.sponsor = this.source.Id.Address;");
            stringBuilder.AppendLine("messengerPackage.target = this.target.Id.Address;");
            return stringBuilder.ToString();
        }
    }
}
